How do I extract a raster's extent in python?How to get raster corner coordinates using Python GDAL...
Single word request: Harming the benefactor
What injury would be of little consequence to a biped but terrible for a quadruped?
How does Dispel Magic work against Stoneskin?
It's a yearly task, alright
Who is our nearest neighbor
Can infringement of a trademark be pursued for using a company's name in a sentence?
Do I need to leave some extra space available on the disk which my database log files reside, for log backup operations to successfully occur?
As a monk, can you make a melee attack roll using your Strength modifier, but roll damage with your Dexterity modifier?
Is a lawful good "antagonist" effective?
Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?
What to do when during a meeting client people start to fight (even physically) with each others?
My story is written in English, but is set in my home country. What language should I use for the dialogue?
Why do Australian milk farmers need to protest supermarkets' milk price?
Time dilation for a moving electronic clock
Best mythical creature to use as livestock?
What Happens when Passenger Refuses to Fly Boeing 737 Max?
How to draw a 3Dbox around a Graph3D result
Welcoming 2019 Pi day: How to draw the letter π?
How is the Swiss post e-voting system supposed to work, and how was it wrong?
How to deal with a cynical class?
Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?
What is the definition of "Natural Selection"?
Question about partial fractions with irreducible quadratic factors
Want to switch to tankless, but can I use my existing wiring?
How do I extract a raster's extent in python?
How to get raster corner coordinates using Python GDAL bindings?Clipping vector data from raster data in ArcGIS Desktop?How do I change a raster's geotransform with GDAL?How to get an extent for Raster using pythonHow to extract subdataset from HDF raster?Can you change the processing extent in environment settings using python to a shapefile?Python - Find the largest extent in a list of extents (tuple format)Increasing extent of Raster?How to mask extract/clip many rasters by a .shp file in python gdal?Changing extent of a raster based on a different rasterR: shapefile extent larger than raster extentHow to prevent rasterFromXYZ from changing my raster extent?
I am looking for an easy way to extract a raster's extent in python.
Currently, I am using gdalinfo and then parsing out the corner coordinates. The problem with this approach is that gdalinfo is not consistent in how it reports the corner coordinates. I am working with a variety of file types (hdf, tif, img, asc, etc). I need the extent to be in decimal degrees (or DMS - that I can convert to decimal degrees).
This is being used with a PostgreSQL database so I have access to any PostGIS function, gdal, or ArcGIS, although I would prefer a function that does not involve ArcGIS unless it is fast (I am trying to index a large number of files, frequently). It can be run on either Windows or Unix.
Thank you,
Kevin
python raster gdal extents
add a comment |
I am looking for an easy way to extract a raster's extent in python.
Currently, I am using gdalinfo and then parsing out the corner coordinates. The problem with this approach is that gdalinfo is not consistent in how it reports the corner coordinates. I am working with a variety of file types (hdf, tif, img, asc, etc). I need the extent to be in decimal degrees (or DMS - that I can convert to decimal degrees).
This is being used with a PostgreSQL database so I have access to any PostGIS function, gdal, or ArcGIS, although I would prefer a function that does not involve ArcGIS unless it is fast (I am trying to index a large number of files, frequently). It can be run on either Windows or Unix.
Thank you,
Kevin
python raster gdal extents
add a comment |
I am looking for an easy way to extract a raster's extent in python.
Currently, I am using gdalinfo and then parsing out the corner coordinates. The problem with this approach is that gdalinfo is not consistent in how it reports the corner coordinates. I am working with a variety of file types (hdf, tif, img, asc, etc). I need the extent to be in decimal degrees (or DMS - that I can convert to decimal degrees).
This is being used with a PostgreSQL database so I have access to any PostGIS function, gdal, or ArcGIS, although I would prefer a function that does not involve ArcGIS unless it is fast (I am trying to index a large number of files, frequently). It can be run on either Windows or Unix.
Thank you,
Kevin
python raster gdal extents
I am looking for an easy way to extract a raster's extent in python.
Currently, I am using gdalinfo and then parsing out the corner coordinates. The problem with this approach is that gdalinfo is not consistent in how it reports the corner coordinates. I am working with a variety of file types (hdf, tif, img, asc, etc). I need the extent to be in decimal degrees (or DMS - that I can convert to decimal degrees).
This is being used with a PostgreSQL database so I have access to any PostGIS function, gdal, or ArcGIS, although I would prefer a function that does not involve ArcGIS unless it is fast (I am trying to index a large number of files, frequently). It can be run on either Windows or Unix.
Thank you,
Kevin
python raster gdal extents
python raster gdal extents
asked Sep 12 '12 at 13:42
kguaykguay
4617
4617
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Probably the python port of gdalinfo would help you. You can see at the top of the file that all the coordinates are reported using the GDALInfoReportCorner method:
#/* -------------------------------------------------------------------- */
#/* Report corners. */
#/* -------------------------------------------------------------------- */
print( "Corner Coordinates:" )
GDALInfoReportCorner( hDataset, hTransform, "Upper Left",
0.0, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Left",
0.0, hDataset.RasterYSize);
GDALInfoReportCorner( hDataset, hTransform, "Upper Right",
hDataset.RasterXSize, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Right",
hDataset.RasterXSize,
hDataset.RasterYSize );
GDALInfoReportCorner( hDataset, hTransform, "Center",
hDataset.RasterXSize/2.0,
hDataset.RasterYSize/2.0 );
you can change the method itself which is implemented at the bottom:
#/************************************************************************/
#/* GDALInfoReportCorner() */
#/************************************************************************/
def GDALInfoReportCorner( hDataset, hTransform, corner_name, x, y ):
line = "%-11s " % corner_name
#/* -------------------------------------------------------------------- */
#/* Transform the point into georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
adfGeoTransform = hDataset.GetGeoTransform(can_return_null = True)
if adfGeoTransform is not None:
dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x
+ adfGeoTransform[2] * y
dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x
+ adfGeoTransform[5] * y
else:
line = line + ("(%7.1f,%7.1f)" % (x, y ))
print(line)
return False
#/* -------------------------------------------------------------------- */
#/* Report the georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
if abs(dfGeoX) < 181 and abs(dfGeoY) < 91:
line = line + ( "(%12.7f,%12.7f) " % (dfGeoX, dfGeoY ))
else:
line = line + ( "(%12.3f,%12.3f) " % (dfGeoX, dfGeoY ))
#/* -------------------------------------------------------------------- */
#/* Transform to latlong and report. */
#/* -------------------------------------------------------------------- */
if hTransform is not None:
pnt = hTransform.TransformPoint(dfGeoX, dfGeoY, 0)
if pnt is not None:
line = line + ( "(%s," % gdal.DecToDMS( pnt[0], "Long", 2 ) )
line = line + ( "%s)" % gdal.DecToDMS( pnt[1], "Lat", 2 ) )
print(line)
return True
Make it print whatever you want :)
Thank you so much for the reply. It looks like that might give me more control over the data then I was getting from gdalinfo. What is the hTransform variable? I have done some research and can't seem to find a simple description of what it should be. Thanks!
– kguay
Sep 13 '12 at 14:30
It is a handle to a coordinate transformation. The link that I gave you to the example is self-contained. You will see it gets created when the dataset has a coordinate system defined hTransform = osr.CoordinateTransformation( hProj, hLatLong )
– Ragi Yaser Burhum
Sep 13 '12 at 17:27
add a comment |
With Arcgis 9.3 I believe it is consistent just WHEN the rasters are georeferenced!.
Then after creating geoprocessing object u can reach it easily with Extent object.
extentofXmin= gp.Describe(rastersource).Extent.Xmin #this is a topleft corner
The other corners respectively reached by Ymin, Xmax, Ymax.
You can see the corner situation in RasterClip in Arcgis like in this img: http://i.stack.imgur.com/aVEWV.png
Unfortunately, this does not give me the coordinates in decimal degrees or DMS.
– kguay
Sep 12 '12 at 14:21
True.. Somehow forgot, as for me it wasn't important the units. So, sorry - no idea how to do it fast. Just looked at arcgis 10 and seems someone has the same problem forums.arcgis.com/threads/…
– najuste
Sep 12 '12 at 14:40
add a comment |
I believe you've almost accomplished your goal parsing gdalinfo. The reason why you have not only decimal degrees is that your data seems to have several CRS. But gdalinfo will provide you with the information of the CRS of the given layer. Only thing you need to do is to create geometry from extent, transform it to the needed CRS (using TransformTo OGR function for example) and extract coordinates once again.
Also you may consider using gdaltindex. Maybe you will need to handle rasters with different CRS somehow, but I believe this will not be a great deal to write proper script. You will get a shp-file with rasters boundaries (and raster names and paths). Transform it to needed CRS and extract corner coordinates of the features.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f33330%2fhow-do-i-extract-a-rasters-extent-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Probably the python port of gdalinfo would help you. You can see at the top of the file that all the coordinates are reported using the GDALInfoReportCorner method:
#/* -------------------------------------------------------------------- */
#/* Report corners. */
#/* -------------------------------------------------------------------- */
print( "Corner Coordinates:" )
GDALInfoReportCorner( hDataset, hTransform, "Upper Left",
0.0, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Left",
0.0, hDataset.RasterYSize);
GDALInfoReportCorner( hDataset, hTransform, "Upper Right",
hDataset.RasterXSize, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Right",
hDataset.RasterXSize,
hDataset.RasterYSize );
GDALInfoReportCorner( hDataset, hTransform, "Center",
hDataset.RasterXSize/2.0,
hDataset.RasterYSize/2.0 );
you can change the method itself which is implemented at the bottom:
#/************************************************************************/
#/* GDALInfoReportCorner() */
#/************************************************************************/
def GDALInfoReportCorner( hDataset, hTransform, corner_name, x, y ):
line = "%-11s " % corner_name
#/* -------------------------------------------------------------------- */
#/* Transform the point into georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
adfGeoTransform = hDataset.GetGeoTransform(can_return_null = True)
if adfGeoTransform is not None:
dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x
+ adfGeoTransform[2] * y
dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x
+ adfGeoTransform[5] * y
else:
line = line + ("(%7.1f,%7.1f)" % (x, y ))
print(line)
return False
#/* -------------------------------------------------------------------- */
#/* Report the georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
if abs(dfGeoX) < 181 and abs(dfGeoY) < 91:
line = line + ( "(%12.7f,%12.7f) " % (dfGeoX, dfGeoY ))
else:
line = line + ( "(%12.3f,%12.3f) " % (dfGeoX, dfGeoY ))
#/* -------------------------------------------------------------------- */
#/* Transform to latlong and report. */
#/* -------------------------------------------------------------------- */
if hTransform is not None:
pnt = hTransform.TransformPoint(dfGeoX, dfGeoY, 0)
if pnt is not None:
line = line + ( "(%s," % gdal.DecToDMS( pnt[0], "Long", 2 ) )
line = line + ( "%s)" % gdal.DecToDMS( pnt[1], "Lat", 2 ) )
print(line)
return True
Make it print whatever you want :)
Thank you so much for the reply. It looks like that might give me more control over the data then I was getting from gdalinfo. What is the hTransform variable? I have done some research and can't seem to find a simple description of what it should be. Thanks!
– kguay
Sep 13 '12 at 14:30
It is a handle to a coordinate transformation. The link that I gave you to the example is self-contained. You will see it gets created when the dataset has a coordinate system defined hTransform = osr.CoordinateTransformation( hProj, hLatLong )
– Ragi Yaser Burhum
Sep 13 '12 at 17:27
add a comment |
Probably the python port of gdalinfo would help you. You can see at the top of the file that all the coordinates are reported using the GDALInfoReportCorner method:
#/* -------------------------------------------------------------------- */
#/* Report corners. */
#/* -------------------------------------------------------------------- */
print( "Corner Coordinates:" )
GDALInfoReportCorner( hDataset, hTransform, "Upper Left",
0.0, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Left",
0.0, hDataset.RasterYSize);
GDALInfoReportCorner( hDataset, hTransform, "Upper Right",
hDataset.RasterXSize, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Right",
hDataset.RasterXSize,
hDataset.RasterYSize );
GDALInfoReportCorner( hDataset, hTransform, "Center",
hDataset.RasterXSize/2.0,
hDataset.RasterYSize/2.0 );
you can change the method itself which is implemented at the bottom:
#/************************************************************************/
#/* GDALInfoReportCorner() */
#/************************************************************************/
def GDALInfoReportCorner( hDataset, hTransform, corner_name, x, y ):
line = "%-11s " % corner_name
#/* -------------------------------------------------------------------- */
#/* Transform the point into georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
adfGeoTransform = hDataset.GetGeoTransform(can_return_null = True)
if adfGeoTransform is not None:
dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x
+ adfGeoTransform[2] * y
dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x
+ adfGeoTransform[5] * y
else:
line = line + ("(%7.1f,%7.1f)" % (x, y ))
print(line)
return False
#/* -------------------------------------------------------------------- */
#/* Report the georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
if abs(dfGeoX) < 181 and abs(dfGeoY) < 91:
line = line + ( "(%12.7f,%12.7f) " % (dfGeoX, dfGeoY ))
else:
line = line + ( "(%12.3f,%12.3f) " % (dfGeoX, dfGeoY ))
#/* -------------------------------------------------------------------- */
#/* Transform to latlong and report. */
#/* -------------------------------------------------------------------- */
if hTransform is not None:
pnt = hTransform.TransformPoint(dfGeoX, dfGeoY, 0)
if pnt is not None:
line = line + ( "(%s," % gdal.DecToDMS( pnt[0], "Long", 2 ) )
line = line + ( "%s)" % gdal.DecToDMS( pnt[1], "Lat", 2 ) )
print(line)
return True
Make it print whatever you want :)
Thank you so much for the reply. It looks like that might give me more control over the data then I was getting from gdalinfo. What is the hTransform variable? I have done some research and can't seem to find a simple description of what it should be. Thanks!
– kguay
Sep 13 '12 at 14:30
It is a handle to a coordinate transformation. The link that I gave you to the example is self-contained. You will see it gets created when the dataset has a coordinate system defined hTransform = osr.CoordinateTransformation( hProj, hLatLong )
– Ragi Yaser Burhum
Sep 13 '12 at 17:27
add a comment |
Probably the python port of gdalinfo would help you. You can see at the top of the file that all the coordinates are reported using the GDALInfoReportCorner method:
#/* -------------------------------------------------------------------- */
#/* Report corners. */
#/* -------------------------------------------------------------------- */
print( "Corner Coordinates:" )
GDALInfoReportCorner( hDataset, hTransform, "Upper Left",
0.0, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Left",
0.0, hDataset.RasterYSize);
GDALInfoReportCorner( hDataset, hTransform, "Upper Right",
hDataset.RasterXSize, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Right",
hDataset.RasterXSize,
hDataset.RasterYSize );
GDALInfoReportCorner( hDataset, hTransform, "Center",
hDataset.RasterXSize/2.0,
hDataset.RasterYSize/2.0 );
you can change the method itself which is implemented at the bottom:
#/************************************************************************/
#/* GDALInfoReportCorner() */
#/************************************************************************/
def GDALInfoReportCorner( hDataset, hTransform, corner_name, x, y ):
line = "%-11s " % corner_name
#/* -------------------------------------------------------------------- */
#/* Transform the point into georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
adfGeoTransform = hDataset.GetGeoTransform(can_return_null = True)
if adfGeoTransform is not None:
dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x
+ adfGeoTransform[2] * y
dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x
+ adfGeoTransform[5] * y
else:
line = line + ("(%7.1f,%7.1f)" % (x, y ))
print(line)
return False
#/* -------------------------------------------------------------------- */
#/* Report the georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
if abs(dfGeoX) < 181 and abs(dfGeoY) < 91:
line = line + ( "(%12.7f,%12.7f) " % (dfGeoX, dfGeoY ))
else:
line = line + ( "(%12.3f,%12.3f) " % (dfGeoX, dfGeoY ))
#/* -------------------------------------------------------------------- */
#/* Transform to latlong and report. */
#/* -------------------------------------------------------------------- */
if hTransform is not None:
pnt = hTransform.TransformPoint(dfGeoX, dfGeoY, 0)
if pnt is not None:
line = line + ( "(%s," % gdal.DecToDMS( pnt[0], "Long", 2 ) )
line = line + ( "%s)" % gdal.DecToDMS( pnt[1], "Lat", 2 ) )
print(line)
return True
Make it print whatever you want :)
Probably the python port of gdalinfo would help you. You can see at the top of the file that all the coordinates are reported using the GDALInfoReportCorner method:
#/* -------------------------------------------------------------------- */
#/* Report corners. */
#/* -------------------------------------------------------------------- */
print( "Corner Coordinates:" )
GDALInfoReportCorner( hDataset, hTransform, "Upper Left",
0.0, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Left",
0.0, hDataset.RasterYSize);
GDALInfoReportCorner( hDataset, hTransform, "Upper Right",
hDataset.RasterXSize, 0.0 );
GDALInfoReportCorner( hDataset, hTransform, "Lower Right",
hDataset.RasterXSize,
hDataset.RasterYSize );
GDALInfoReportCorner( hDataset, hTransform, "Center",
hDataset.RasterXSize/2.0,
hDataset.RasterYSize/2.0 );
you can change the method itself which is implemented at the bottom:
#/************************************************************************/
#/* GDALInfoReportCorner() */
#/************************************************************************/
def GDALInfoReportCorner( hDataset, hTransform, corner_name, x, y ):
line = "%-11s " % corner_name
#/* -------------------------------------------------------------------- */
#/* Transform the point into georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
adfGeoTransform = hDataset.GetGeoTransform(can_return_null = True)
if adfGeoTransform is not None:
dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x
+ adfGeoTransform[2] * y
dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x
+ adfGeoTransform[5] * y
else:
line = line + ("(%7.1f,%7.1f)" % (x, y ))
print(line)
return False
#/* -------------------------------------------------------------------- */
#/* Report the georeferenced coordinates. */
#/* -------------------------------------------------------------------- */
if abs(dfGeoX) < 181 and abs(dfGeoY) < 91:
line = line + ( "(%12.7f,%12.7f) " % (dfGeoX, dfGeoY ))
else:
line = line + ( "(%12.3f,%12.3f) " % (dfGeoX, dfGeoY ))
#/* -------------------------------------------------------------------- */
#/* Transform to latlong and report. */
#/* -------------------------------------------------------------------- */
if hTransform is not None:
pnt = hTransform.TransformPoint(dfGeoX, dfGeoY, 0)
if pnt is not None:
line = line + ( "(%s," % gdal.DecToDMS( pnt[0], "Long", 2 ) )
line = line + ( "%s)" % gdal.DecToDMS( pnt[1], "Lat", 2 ) )
print(line)
return True
Make it print whatever you want :)
edited 1 min ago
naught101
296515
296515
answered Sep 12 '12 at 20:58
Ragi Yaser BurhumRagi Yaser Burhum
14.3k25476
14.3k25476
Thank you so much for the reply. It looks like that might give me more control over the data then I was getting from gdalinfo. What is the hTransform variable? I have done some research and can't seem to find a simple description of what it should be. Thanks!
– kguay
Sep 13 '12 at 14:30
It is a handle to a coordinate transformation. The link that I gave you to the example is self-contained. You will see it gets created when the dataset has a coordinate system defined hTransform = osr.CoordinateTransformation( hProj, hLatLong )
– Ragi Yaser Burhum
Sep 13 '12 at 17:27
add a comment |
Thank you so much for the reply. It looks like that might give me more control over the data then I was getting from gdalinfo. What is the hTransform variable? I have done some research and can't seem to find a simple description of what it should be. Thanks!
– kguay
Sep 13 '12 at 14:30
It is a handle to a coordinate transformation. The link that I gave you to the example is self-contained. You will see it gets created when the dataset has a coordinate system defined hTransform = osr.CoordinateTransformation( hProj, hLatLong )
– Ragi Yaser Burhum
Sep 13 '12 at 17:27
Thank you so much for the reply. It looks like that might give me more control over the data then I was getting from gdalinfo. What is the hTransform variable? I have done some research and can't seem to find a simple description of what it should be. Thanks!
– kguay
Sep 13 '12 at 14:30
Thank you so much for the reply. It looks like that might give me more control over the data then I was getting from gdalinfo. What is the hTransform variable? I have done some research and can't seem to find a simple description of what it should be. Thanks!
– kguay
Sep 13 '12 at 14:30
It is a handle to a coordinate transformation. The link that I gave you to the example is self-contained. You will see it gets created when the dataset has a coordinate system defined hTransform = osr.CoordinateTransformation( hProj, hLatLong )
– Ragi Yaser Burhum
Sep 13 '12 at 17:27
It is a handle to a coordinate transformation. The link that I gave you to the example is self-contained. You will see it gets created when the dataset has a coordinate system defined hTransform = osr.CoordinateTransformation( hProj, hLatLong )
– Ragi Yaser Burhum
Sep 13 '12 at 17:27
add a comment |
With Arcgis 9.3 I believe it is consistent just WHEN the rasters are georeferenced!.
Then after creating geoprocessing object u can reach it easily with Extent object.
extentofXmin= gp.Describe(rastersource).Extent.Xmin #this is a topleft corner
The other corners respectively reached by Ymin, Xmax, Ymax.
You can see the corner situation in RasterClip in Arcgis like in this img: http://i.stack.imgur.com/aVEWV.png
Unfortunately, this does not give me the coordinates in decimal degrees or DMS.
– kguay
Sep 12 '12 at 14:21
True.. Somehow forgot, as for me it wasn't important the units. So, sorry - no idea how to do it fast. Just looked at arcgis 10 and seems someone has the same problem forums.arcgis.com/threads/…
– najuste
Sep 12 '12 at 14:40
add a comment |
With Arcgis 9.3 I believe it is consistent just WHEN the rasters are georeferenced!.
Then after creating geoprocessing object u can reach it easily with Extent object.
extentofXmin= gp.Describe(rastersource).Extent.Xmin #this is a topleft corner
The other corners respectively reached by Ymin, Xmax, Ymax.
You can see the corner situation in RasterClip in Arcgis like in this img: http://i.stack.imgur.com/aVEWV.png
Unfortunately, this does not give me the coordinates in decimal degrees or DMS.
– kguay
Sep 12 '12 at 14:21
True.. Somehow forgot, as for me it wasn't important the units. So, sorry - no idea how to do it fast. Just looked at arcgis 10 and seems someone has the same problem forums.arcgis.com/threads/…
– najuste
Sep 12 '12 at 14:40
add a comment |
With Arcgis 9.3 I believe it is consistent just WHEN the rasters are georeferenced!.
Then after creating geoprocessing object u can reach it easily with Extent object.
extentofXmin= gp.Describe(rastersource).Extent.Xmin #this is a topleft corner
The other corners respectively reached by Ymin, Xmax, Ymax.
You can see the corner situation in RasterClip in Arcgis like in this img: http://i.stack.imgur.com/aVEWV.png
With Arcgis 9.3 I believe it is consistent just WHEN the rasters are georeferenced!.
Then after creating geoprocessing object u can reach it easily with Extent object.
extentofXmin= gp.Describe(rastersource).Extent.Xmin #this is a topleft corner
The other corners respectively reached by Ymin, Xmax, Ymax.
You can see the corner situation in RasterClip in Arcgis like in this img: http://i.stack.imgur.com/aVEWV.png
answered Sep 12 '12 at 14:06
najustenajuste
4521716
4521716
Unfortunately, this does not give me the coordinates in decimal degrees or DMS.
– kguay
Sep 12 '12 at 14:21
True.. Somehow forgot, as for me it wasn't important the units. So, sorry - no idea how to do it fast. Just looked at arcgis 10 and seems someone has the same problem forums.arcgis.com/threads/…
– najuste
Sep 12 '12 at 14:40
add a comment |
Unfortunately, this does not give me the coordinates in decimal degrees or DMS.
– kguay
Sep 12 '12 at 14:21
True.. Somehow forgot, as for me it wasn't important the units. So, sorry - no idea how to do it fast. Just looked at arcgis 10 and seems someone has the same problem forums.arcgis.com/threads/…
– najuste
Sep 12 '12 at 14:40
Unfortunately, this does not give me the coordinates in decimal degrees or DMS.
– kguay
Sep 12 '12 at 14:21
Unfortunately, this does not give me the coordinates in decimal degrees or DMS.
– kguay
Sep 12 '12 at 14:21
True.. Somehow forgot, as for me it wasn't important the units. So, sorry - no idea how to do it fast. Just looked at arcgis 10 and seems someone has the same problem forums.arcgis.com/threads/…
– najuste
Sep 12 '12 at 14:40
True.. Somehow forgot, as for me it wasn't important the units. So, sorry - no idea how to do it fast. Just looked at arcgis 10 and seems someone has the same problem forums.arcgis.com/threads/…
– najuste
Sep 12 '12 at 14:40
add a comment |
I believe you've almost accomplished your goal parsing gdalinfo. The reason why you have not only decimal degrees is that your data seems to have several CRS. But gdalinfo will provide you with the information of the CRS of the given layer. Only thing you need to do is to create geometry from extent, transform it to the needed CRS (using TransformTo OGR function for example) and extract coordinates once again.
Also you may consider using gdaltindex. Maybe you will need to handle rasters with different CRS somehow, but I believe this will not be a great deal to write proper script. You will get a shp-file with rasters boundaries (and raster names and paths). Transform it to needed CRS and extract corner coordinates of the features.
add a comment |
I believe you've almost accomplished your goal parsing gdalinfo. The reason why you have not only decimal degrees is that your data seems to have several CRS. But gdalinfo will provide you with the information of the CRS of the given layer. Only thing you need to do is to create geometry from extent, transform it to the needed CRS (using TransformTo OGR function for example) and extract coordinates once again.
Also you may consider using gdaltindex. Maybe you will need to handle rasters with different CRS somehow, but I believe this will not be a great deal to write proper script. You will get a shp-file with rasters boundaries (and raster names and paths). Transform it to needed CRS and extract corner coordinates of the features.
add a comment |
I believe you've almost accomplished your goal parsing gdalinfo. The reason why you have not only decimal degrees is that your data seems to have several CRS. But gdalinfo will provide you with the information of the CRS of the given layer. Only thing you need to do is to create geometry from extent, transform it to the needed CRS (using TransformTo OGR function for example) and extract coordinates once again.
Also you may consider using gdaltindex. Maybe you will need to handle rasters with different CRS somehow, but I believe this will not be a great deal to write proper script. You will get a shp-file with rasters boundaries (and raster names and paths). Transform it to needed CRS and extract corner coordinates of the features.
I believe you've almost accomplished your goal parsing gdalinfo. The reason why you have not only decimal degrees is that your data seems to have several CRS. But gdalinfo will provide you with the information of the CRS of the given layer. Only thing you need to do is to create geometry from extent, transform it to the needed CRS (using TransformTo OGR function for example) and extract coordinates once again.
Also you may consider using gdaltindex. Maybe you will need to handle rasters with different CRS somehow, but I believe this will not be a great deal to write proper script. You will get a shp-file with rasters boundaries (and raster names and paths). Transform it to needed CRS and extract corner coordinates of the features.
answered Sep 12 '12 at 20:25
SS_RebeliousSS_Rebelious
4,63111953
4,63111953
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f33330%2fhow-do-i-extract-a-rasters-extent-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown