How to use the function in fiona

To help you get started, we’ve selected a few fiona 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 fitnr / svgis / svgis / cli / View on Github external
def pick_projection(project):
    use_proj, out_crs = None, None

    if project.lower() in ('local', 'utm'):
        use_proj = project.lower()

    elif os.path.exists(project):
        # Is a file
        with open(project) as f:
            out_crs =

    elif project[:5].lower() == 'epsg:':
        # Is an epsg code
        _, epsg = project.split(':')
        out_crs =

        # Assume it's a proj4 string.
        # returns {} if it isn't.
        out_crs =

    return use_proj, out_crs
github geopandas / geopandas / geopandas / tools / View on Github external
def epsg_from_crs(crs):
    Returns an epsg code from a crs dict or Proj string.

    crs : dict or string, default None
        A crs dict or Proj string

    if crs is None:
        raise ValueError("No crs provided.")
    if isinstance(crs, str):
        crs =
    if not crs:
        raise ValueError("Empty or invalid crs provided")
    if "init" in crs and crs["init"].lower().startswith("epsg:"):
        return int(crs["init"].split(":")[1])
github OpenDataAnalytics / gaia / gaia / View on Github external
:return: EPSG code (integer)
        if is None:
        if == 'GeoDataFrame':
            if is None:
                # Make educated guess about projection based on longitude coords
                minx = min(['minx'])
                maxx = max(['maxx'])
                if minx >= -180.0 and maxx <= 180.0:
                    self.epsg = 4326
           = fiona_crs.from_epsg(self.epsg)
                elif minx >= -20026376.39 and maxx <= 20026376.39:
                    self.epsg = 3857
           = fiona_crs.from_epsg(self.epsg)
                    raise GaiaException('Could not determine data projection.')
                return self.epsg
                crs ='init', None)
                if crs:
                    if ':' in crs:
                        crs = crs.split(':')[1]
                    if crs.isdigit():
                        self.epsg = int(crs)
                        return self.epsg
                    # Assume EPSG:4326
                    self.epsg = 4326
           = fiona_crs.from_epsg(self.epsg)
                    return self.epsg
github agile-geoscience / geotransect / View on Github external
line_out_file = os.path.join(output_dir, "seismic_lines.shp")

    if os.path.exists(line_out_file):
        raise ShapeFileExists

    # Set up the shapefile schema.
    line_schema = {'geometry': 'LineString',
                   'properties': {'segyfile': 'str',
                                  'line': 'str'

    with, "w",
                    driver="ESRI Shapefile",
                    schema=line_schema) as line_out:

        for path in utils.walk(input_dir, "\\.se?gy$"):

            filebase = os.path.splitext(os.path.basename(path))[0]

            # Read in the headers.
            segy =,

            points = []

            point_out_file = os.path.join(output_dir, "." +
                                          filebase + '.shp')
github OpenDataAnalytics / gaia / gaia / geo / View on Github external
def reproject(dataset, epsg):
    Reproject a dataset to the specified EPSG code

    :param dataset: Dataset to reproject
    :param epsg: EPSG code to reproject to
    :return: Reprojected data
    dataclass = dataset.__class__.__name__
    # Run appropriate reprojection method
    if dataclass == 'GeoDataFrame':
        repro = geopandas.GeoDataFrame.copy(dataclass)
        repro[] = repro.geometry.to_crs(epsg=epsg) =
    elif dataclass == 'Dataset':
        repro = gdal_reproject(dataset, '', epsg=epsg)
    return repro
github jwass / geopandas_osm / geopandas_osm / View on Github external
import collections
import xml.etree.ElementTree as ET

import geopandas as gpd
from import urlopen, urlencode
import pandas as pd
from shapely.geometry import Point, LineString
from six import string_types

OSMData = collections.namedtuple('OSMData', ('nodes', 'waynodes', 'waytags',
                                             'relmembers', 'reltags'))
_crs =

# Tags to remove so we don't clobber the output. This list comes from
# osmtogeojson's index.js (
uninteresting_tags = set([
github kuanb / peartree / peartree / View on Github external
def generate_empty_md_graph(name: str,
                            init_crs: Dict=crs.from_epsg(WGS84)):
    Generates an empty multi-directed graph.

    name : str
        The name of the graph
    init_crs : dict
        The coordinate reference system to be assigned to the graph. Example \
        CRS would be `{'init': 'epsg:4326'}`

    G : nx.MultiDiGraph
        The muti-directed graph
github OpenDataAnalytics / gaia / gaia / geo / View on Github external
original_projection = featureio.get_epsg()
        epsg = original_projection
        srs = osr.SpatialReference()
        if not srs.GetAttrValue('UNIT').lower().startswith('met'):
            epsg = 3857
            original_projection = None
        feature_df =
        buffer = GeoSeries(feature_df.buffer(self.buffer_size).unary_union)
        buffer_df = GeoDataFrame(geometry=buffer) =
        if original_projection:
            buffer_df[] = buffer_df.to_crs(
        return buffer_df