Defining projections for SHP files

Source: Internet
Author: User

#!/usr/bin/env python
#-*-Coding:utf-8-*-

Import Urllib.request
Import OS

def get_epsg_code (EPSG):
"""
Get the ESRI formatted. PRJ definition
Usage Get_epsg_code (4326)

We Use the http://spatialreference.org/ref/epsg/4326/esriwkt/
"""

F=urllib.request.urlopen ("http://spatialreference.org/ref/epsg/{0}/esriwkt/". Format (EPSG))
Return (F.read ())

# Shapefile filename must equal the new PRJ filename
Shp_filename = "Utm_zone_boundaries"

# path to where Shapefiles with No. prj is located
Os.chdir (".. /geodata/")

# Here we write out a new. prj file with the same name
# as our shapefiles named "Schools" in this example

With open ("%s.prj"% Shp_filename, "WB") as PRJ:
Epsg_code = Get_epsg_code (4326)
Print (Epsg_code)
Prj.write (Epsg_code)
Print ("Done writing projection definition" + prj.name + "to EPSG:" + str (epsg_code))

# now change abck to our code directory
Os.chdir (".. /code/")

Defining projections for SHP files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.