Created
October 29, 2020 09:27
-
-
Save BishopGIS/676971982ba499b0c5ecc0168cb3668b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from osgeo import gdal | |
from osgeo import ogr | |
from osgeo import osr | |
base_url = 'https://sandbox.nextgis.com' | |
service = 6038 | |
version = '1.0.0' | |
gdal.SetConfigOption("CPL_DEBUG", "ON") | |
gdal.SetConfigOption("CPL_CURL_VERBOSE", "YES") | |
driver = ogr.GetDriverByName('WFS') | |
wfs_ds = driver.Open("WFS:{}/api/resource/{}/wfs?VERSION={}".format( | |
base_url, service, version), True) | |
wfs_layer = wfs_ds.GetLayer(0) | |
feature = wfs_layer.GetNextFeature() | |
geom = feature.GetGeometryRef() | |
geom_wkt = 'MULTIPOLYGON( ((0 0,1 1,1 0,0 0)),((0 0,10 0, 10 10, 0 10),(1 1,1 2,2 2,2 1)) )' | |
srs = ogr.osr.SpatialReference() | |
srs.ImportFromEPSG(4326) | |
srs1 = ogr.osr.SpatialReference() | |
srs1.ImportFromEPSG(3857) | |
ct = osr.CoordinateTransformation(srs, srs1) | |
geom = ogr.CreateGeometryFromWkt(geom_wkt) | |
geom.AssignSpatialReference(srs) | |
geom.Transform(ct) | |
feature.SetGeometry(geom) | |
print(wfs_layer.SetFeature(feature)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment