I have a shapefile from a city
I want to define a 10 km buffer around this shape file.
How can I define this buffer?
I am not sure what do you mean with buffer, do you want to add like a circle +10km centered in the city?
Hi thanks for your response
I meen buffer around the shape of a vector file(city shape file), not specific shape like circle.
Hi @Mohammad_Gh ,
So take the external shape of your shape file and an offset of +10km?
Thanks, exactly yes
I looked around and I believe that snap does not have this functionality as it is not a trivial task.
The simplest way would probably be to write a python script that:
- Find the center of the city shape (or you select/set one)
- Find all the external points of your shape file and project them out of +10km
However if the shape file is complex find all the external point could take very long.
I will try to write a simple script and I will post it.
Thanks for your response mr @MartinoF
Thanks a lot
I made a small script that takes as input a shape file and an offset (the offset is not really in km as the Geographical coordinate system is not in km) and create a new shapefile containing the offset geometry.
You can find the script here: github or attached to the post (but I will only update the github one)
To execute the script you will need
matplotlib (this is only for the visualization).
This is the result from a shape file with around 40’000 points:
To execute the script type:
python3 shapeoffset.py PATH_TO_YOUR_FILE.shp OFFSET_VALUE
The script will create a new file containing the offset polygon named:
If you want to visualize the shape before saving it add the argument
shapeoffset.py (4.2 KB)
Thank you very much for your cooperation.
By trial and error, I was able to create the buffer.
I wish you and your team success.