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.
I have S2 data i wanna do buffering 10km in same data its possible ?
If any idea please guide
SNAP does not provide much vector tools.
You can create the buffer outside SNAP (e.g. in QGIS), then import it as a Shapefile and then use it as valid pixel expression to make all pixels outside the polygon transparent.
Yes, true. SNAP is not a real GIS application and does not support much vector operations.
But you could draw the circle manually once and export either as WKT or shapefile. An then you can import it into other products and use it for masking or use it in processing.
Thank you for help…I created shapefile using geometry as shapefile and then imported shp file in existing product kindly please tell next step to complete
Sentinel you save the product, close it and open it again. You will see the imported geometry as a mask as part of the product.
Use its name in the band properties under valid pixel expression. This will remove all pixels outside the maks from the view (at least visually).