當前位置: 首頁>>代碼示例>>Python>>正文


Python geometry.GEOSGeometry方法代碼示例

本文整理匯總了Python中django.contrib.gis.geos.geometry.GEOSGeometry方法的典型用法代碼示例。如果您正苦於以下問題:Python geometry.GEOSGeometry方法的具體用法?Python geometry.GEOSGeometry怎麽用?Python geometry.GEOSGeometry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.contrib.gis.geos.geometry的用法示例。


在下文中一共展示了geometry.GEOSGeometry方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: fromfile

# 需要導入模塊: from django.contrib.gis.geos import geometry [as 別名]
# 或者: from django.contrib.gis.geos.geometry import GEOSGeometry [as 別名]
def fromfile(file_h):
    """
    Given a string file name, returns a GEOSGeometry. The file may contain WKB,
    WKT, or HEX.
    """
    # If given a file name, get a real handle.
    if isinstance(file_h, six.string_types):
        with open(file_h, 'rb') as file_h:
            buf = file_h.read()
    else:
        buf = file_h.read()

    # If we get WKB need to wrap in memoryview(), so run through regexes.
    if isinstance(buf, bytes):
        try:
            decoded = buf.decode()
            if wkt_regex.match(decoded) or hex_regex.match(decoded):
                return GEOSGeometry(decoded)
        except UnicodeDecodeError:
            pass
    else:
        return GEOSGeometry(buf)

    return GEOSGeometry(six.memoryview(buf)) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:26,代碼來源:factory.py

示例2: fromfile

# 需要導入模塊: from django.contrib.gis.geos import geometry [as 別名]
# 或者: from django.contrib.gis.geos.geometry import GEOSGeometry [as 別名]
def fromfile(file_h):
    """
    Given a string file name, returns a GEOSGeometry. The file may contain WKB,
    WKT, or HEX.
    """
    # If given a file name, get a real handle.
    if isinstance(file_h, six.string_types):
        with open(file_h, 'rb') as file_h:
            buf = file_h.read()
    else:
        buf = file_h.read()

    # If we get WKB need to wrap in memoryview(), so run through regexes.
    if isinstance(buf, bytes):
        try:
            decoded = buf.decode()
            if wkt_regex.match(decoded) or hex_regex.match(decoded):
                return GEOSGeometry(decoded)
        except UnicodeDecodeError:
            pass
    else:
        return GEOSGeometry(buf)

    return GEOSGeometry(memoryview(buf)) 
開發者ID:VirtualPlants,項目名稱:tissuelab,代碼行數:26,代碼來源:factory.py

示例3: load_cities

# 需要導入模塊: from django.contrib.gis.geos import geometry [as 別名]
# 或者: from django.contrib.gis.geos.geometry import GEOSGeometry [as 別名]
def load_cities():
    City.objects.all().delete()

    with open(os.path.join(os.path.dirname(__file__), 'data', 'cities1000.txt'), 'r') as csv_file:
        csv_reader = csv.reader(csv_file, delimiter='\t')
        for row in csv_reader:
            try:
                country = WorldBorder.objects.get(iso2=row[8])
            except WorldBorder.DoesNotExist:
                country = None
            City(
                name        = row[1],
                timezone    = row[17],
                location    = GEOSGeometry('POINT({} {})'.format(row[5], row[4])),
                population  = row[14],
                country     = country,
            ).save() 
開發者ID:damianmoore,項目名稱:photo-manager,代碼行數:19,代碼來源:load.py

示例4: handle

# 需要導入模塊: from django.contrib.gis.geos import geometry [as 別名]
# 或者: from django.contrib.gis.geos.geometry import GEOSGeometry [as 別名]
def handle(self, **options):
        path = options['path'][0]
        column = options['column'][0]
        model = options['model'][0]
        
        
        
        with fiona.open(path) as src:
            print json.dumps(src.schema, indent=4)
            print src.crs
            for feat in src:
                
                #print feat['geometry']['type']
                s = shape(feat['geometry'])
                if feat['geometry']['type'] == 'Polygon':
                    s = MultiPolygon([s])
                    print json.dumps(feat['geometry'])
                klass = locate('madmex.models.%s' % model)
                
                f = klass(name=feat['properties'][column], the_geom=GEOSGeometry(s.wkt))
                f.save() 
開發者ID:CONABIO,項目名稱:antares,代碼行數:23,代碼來源:shape.py

示例5: fromstr

# 需要導入模塊: from django.contrib.gis.geos import geometry [as 別名]
# 或者: from django.contrib.gis.geos.geometry import GEOSGeometry [as 別名]
def fromstr(string, **kwargs):
    "Given a string value, returns a GEOSGeometry object."
    return GEOSGeometry(string, **kwargs) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:5,代碼來源:factory.py

示例6: read

# 需要導入模塊: from django.contrib.gis.geos import geometry [as 別名]
# 或者: from django.contrib.gis.geos.geometry import GEOSGeometry [as 別名]
def read(self, wkb):
        "Returns a GEOSGeometry for the given WKB buffer."
        return GEOSGeometry(super(WKBReader, self).read(wkb)) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:5,代碼來源:io.py


注:本文中的django.contrib.gis.geos.geometry.GEOSGeometry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。