WARNING: Shapefile and image are not the same projection

42 views
Skip to first unread message

Josh Jones

unread,
Apr 16, 2018, 5:00:00 AM4/16/18
to RSGISLib Support

Hi Pete, Dan and everyone else,

I'm trying to calculate some zonal stats for a stack of KEA images within a shapefile. Despite warping and projection them to the same projection I always get the same error message as GDAL seems to write the projection info in a very slightly different way for the same projection (OSGB36). I've tried manually editing the .proj file of the shapefile but the changes never stick and there is always at least one slight difference.

Is there a fix for this in GDAL ORG or RSGISLib?

Thanks,

Josh


# make sure the layer are in exactly the same projection
print('Reprojecting shapefile')
call
(["ogr2ogr", "-t_srs", "EPSG:27700", "./data/GB_CCM21_elementary_OSGB36_proj.shp",  "./data/GB_CCM21_elementary_OSGB36.shp"])

call
(["gdalwarp", "-t_srs", "EPSG:27700", "./data/GB_covariables_stack.kea", "./data/GB_covariables_stack_proj.kea"])

# extract zonal stats for elementary catchments
imagestack
= './data/GB_covariables_stack_proj.kea'
inputvector
= './data/GB_CCM21_elementary_OSGB36_proj.shp'
outputtxt
= './output/GB_CCM21_elementary_covars.txt'
zonalattributes
= zonalstats.ZonalAttributes(minThreshold=0, maxThreshold=10000, calcCount=False, calcMin=True, calcMax=True, calcMean=True, calcStdDev=True, calcMode=False, calcSum=False)
rsgislib
.zonalstats.pixelStats2TXT(imagestack, inputvector, outputtxt, zonalattributes, True, False, zonalstats.METHOD_POLYCONTAINSPIXELCENTER, True)



WARNING
: Shapefile and image are not the same projection!
   
Image is: PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB_1936",SPHEROID["Airy_1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]
   
Shapefile is: PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB_1936",SPHEROID["Airy_1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4277"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]
...Continuing anyway
Started, 25762 features to process.
0% Done
Segmentation fault (core dumped)

Pete Bunting [pfb]

unread,
Apr 16, 2018, 5:09:30 AM4/16/18
to Josh Jones, RSGISLib Support
Hi Josh,

I don’t know the cause of the error but it isn’t because of the warning about projections.

Probably check that all your polygons are valid - there is a tool in QGIS and you can also check things using: rsgislib.vectorutils.printpolygeom

Otherwise, I’d probably need to look at an example dataset which exhibits the issue.

Cheers Pete


From: rsgislib...@googlegroups.com <rsgislib...@googlegroups.com> on behalf of Josh Jones <joshua.a...@gmail.com>
Sent: Monday, April 16, 2018 9:00:00 PM
To: RSGISLib Support
Subject: [rsgislib-support] WARNING: Shapefile and image are not the same projection
 
--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.


--------------------------------------------------------------------
Prifysgol Aberystwyth www.aber.ac.uk
Prifysgol y Flwyddyn ar gyfer Ansawdd Dysgu - The Times & The Sunday Times 2018.

Aberystwyth University www.aber.ac.uk
University of the Year for Teaching Quality - The Times & The Sunday Times 2018.

Josh Jones

unread,
Apr 16, 2018, 7:45:39 AM4/16/18
to RSGISLib Support
Thanks for the speedy response Pete.

Geometry seems to be valid.

Sample data available at the link if you have a minute. The shapefiles are derived from a spatial join between the original catchment .gdb and shapefile of points.

https://drive.google.com/open?id=1NXCV27QREI92V10f00qqSbgX09vzMOEf

Thanks,

Josh
To post to this group, send email to rsgisli...@googlegroups.com.

Daniel Clewley

unread,
Apr 20, 2018, 2:14:56 AM4/20/18
to Josh Jones, RSGISLib Support
Hi Josh,

I’ve had a quick look and also get the same error. It is quite a complicated shapefile with lots of polygons so would recommend checking this as Pete suggested. I’ll try and have a more detailed look later.

As for the projection error there is an argument so it doesn’t print projection warnings (noProjWarning) you are setting this to False, if you set it to True you won’t get the warning about projection.

Thanks,

Dan

To post to this group, send email to rsgislib...@googlegroups.com.

Josh Jones

unread,
Apr 20, 2018, 8:14:23 AM4/20/18
to RSGISLib Support
Hi Dan,

QGIS geometry validity tool didn't return any errors. I've since used subsetImgs2CommonExtent to make sure the stack was correct. But still getting

...Continuing anyway
Started, 25762 features to process.
0% Done
Segmentation fault (core dumped)


New image stack here as some of the images in the stack weren't landing in the right place before https://drive.google.com/open?id=1WCSB_P04VslVGgtQyjkbClm1wAeq00BZ

Thanks for having a look,

Josh
Reply all
Reply to author
Forward
0 new messages