How to use the geomet.wkt.dumps function in geomet

To help you get started, we’ve selected a few geomet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sentinelsat / sentinelsat / sentinelsat / sentinel.py View on Github external
return geometry[:2]

    def check_bounds(geometry):
        if isinstance(geometry[0], (list, tuple)):
            return list(map(check_bounds, geometry))
        else:
            if geometry[0] > 180 or geometry[0] < -180:
                raise ValueError("Longitude is out of bounds, check your JSON format or data")
            if geometry[1] > 90 or geometry[1] < -90:
                raise ValueError("Latitude is out of bounds, check your JSON format or data")

    # Discard z-coordinate, if it exists
    geometry["coordinates"] = ensure_2d(geometry["coordinates"])
    check_bounds(geometry["coordinates"])

    wkt = geomet.wkt.dumps(geometry, decimals=decimals)
    # Strip unnecessary spaces
    wkt = re.sub(r"(?
github ADEQUATeDQ / portalmonitor / odpw / core / dataset_converter.py View on Github external
g.add((spatial_ref, RDF.type, DCT.Location))
            g.add((dataset_ref, DCT.spatial, spatial_ref))

            if spatial_text:
                g.add((spatial_ref, SKOS.prefLabel, Literal(spatial_text)))

            if spatial_geom:
                # GeoJSON
                g.add((spatial_ref,
                       LOCN.geometry,
                       Literal(spatial_geom, datatype=GEOJSON_IMT)))
                # WKT, because GeoDCAT-AP says so
                try:
                    g.add((spatial_ref,
                           LOCN.geometry,
                           Literal(wkt.dumps(json.loads(spatial_geom),
                                             decimals=4),
                                   datatype=GSP.wktLiteral)))
                except (TypeError, ValueError, InvalidGeoJSONException):
                    pass

        # License
        license_id = self._get_dataset_value(dataset_dict, 'license_id', default='')
        license_url = self._get_dataset_value(dataset_dict, 'license_url', default='')
        license_title = self._get_dataset_value(dataset_dict, 'license_title', default='')
        license = None
        if license_id or license_url or license_title:
            if license_url and bool(urlparse.urlparse(license_url).netloc):
                license = URIRef(license_url)
            else:
                id_string = dataset_ref.n3() + DCT.license.n3() + license_id + license_url + license_title
                bnode_hash = hashlib.sha1(id_string.encode('utf-8'))
github ADEQUATeDQ / portalmonitor / odpw / utils / dataset_converter.py View on Github external
g.add((spatial_ref, RDF.type, DCT.Location))
            g.add((dataset_ref, DCT.spatial, spatial_ref))

            if spatial_text:
                g.add((spatial_ref, SKOS.prefLabel, Literal(spatial_text)))

            if spatial_geom:
                # GeoJSON
                g.add((spatial_ref,
                       LOCN.geometry,
                       Literal(spatial_geom, datatype=GEOJSON_IMT)))
                # WKT, because GeoDCAT-AP says so
                try:
                    g.add((spatial_ref,
                           LOCN.geometry,
                           Literal(wkt.dumps(json.loads(spatial_geom),
                                             decimals=4),
                                   datatype=GSP.wktLiteral)))
                except (TypeError, ValueError, InvalidGeoJSONException):
                    pass

        # License
        license_id = self._get_dataset_value(dataset_dict, 'license_id')
        license_url = self._get_dataset_value(dataset_dict, 'license_url')
        license_title = self._get_dataset_value(dataset_dict, 'license_title')
        license = None
        if license_id or license_url or license_title:
            if license_url and bool(urlparse.urlparse(license_url).netloc):
                license = URIRef(license_url)
            else:
                license = BNode()
                # maybe a non-valid url

geomet

Pure Python conversion library for common geospatial data formats

Apache-2.0
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis