Thursday 26 November 2015

python - How to easily shift all features in a vector dataset?


Let's say that I put together a Shapefile and all the features have their vertices shifted by a constant amount. What's the easiest way of shifting all the features (hence the (x,y) position of their vertices) by an arbitrary shift? I have lots of files that I would apply this correction to, so a Bash/OGR answer would be preferred :)


Finally, I ended up using Spatialite for this, as it has the nice function ShiftCoords. However, the thread was very informative! Thanks all!




Answer



Using JEQL This can be done with three lines:


ShapefileReader t file: "shapefile.shp";
out = select * except (GEOMETRY), Geom.translate(GEOMETRY,100,100) from t;
ShapefileWriter out file: "ahapefile_shift.shp";

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...