由於VISSIm Synchro等交通類的軟件 要加載GIS 資源的background底圖資源,而直接加載GIS(shp格式)資源后,發現很小,甚至沒有底圖,無法顯示.尤其是Synchro軟件加載GIS資源底圖后,左上角Xy 和右下角XY 都是整數,直接重合,在軟件上無顯示.開始我想 把坐標系的XY 都放大10000倍,就可以顯示了.其實我真是不專業啊...
由於我給的GIS資源shp文件的坐標系是GPS標准坐標系WGS1984,XY范圍 是 -180到180度,-90度到90度,而我們這個地區連1度都沒有的.想要XY變大很簡單,將地理坐標系投影轉換為平面坐標系就可以了.
平面坐標系,比如西安80(大約在arcgis坐標系文件夾的 投影/高斯 下面),我使用了WGS1984的一種web平面坐標系,ID是102100(在該網站可以看到arcgis定義的ID和對應的坐標系名稱以及坐標系的參數).
用catalog或arcmap的tooolbox工具箱的 數據工具/投影轉換/投影 工具可以進行轉換,在結果顯示,從結果可以復制python腳本,然后自己編輯python腳本來調用轉換過程.貌似python中間不要加上中文路徑,或者子python上面添加編碼聲明.
下面是我的python腳本(從ArcGIS工具箱復制python腳本修改的)
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "Rshenzhen"
import arcpy;
in_dataset="F:/1.EnglishDir/m2 shenzhen x10000/road/Rshenzhen_polyline.shp"
out_dataset="F:/1.EnglishDir/document/prj/rshenzhen_project3.shp"
out_coor_system="PROJCS['WGS_1984_Web_Mercator_Auxiliary_Sphere',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator_Auxiliary_Sphere'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Auxiliary_Sphere_Type',0.0],UNIT['Meter',1.0]]"
transform_method="#"
in_coor_system="GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]"
arcpy.Project_management(in_dataset,out_dataset,out_coor_system,transform_method,in_coor_system)
Python真是很有意思的語言,很想學,只是不知用處以及不知如何提高工作效率,而且學習難度費記憶啊.
下面是在python中輸入help(arcpy.Project_management)的結果.附上一個linux下gtk類腳本的模板.
View Code
"""
help(Project_management);
Help on function Project in module arcpy.management:
Project(in_dataset=None, out_dataset=None, out_coor_system=None, transform_method=None, in_coor_system=None)
Project_management(in_dataset, out_dataset, out_coor_system, {transform_method;transform_method...}, {in_coor_system})
Creates a new dataset or feature class with the coordinate system specified.
* If the input is a feature class Features from the input feature class are
projected to the new coordinate system and written to the output feature class.
* If the input is a feature dataset ll feature classes in the input feature
dataset will be projected to the new coordinate system and written to the output
feature dataset.
INPUTS:
in_dataset (Feature Layer or Feature Dataset):
The feature class, feature layer, or feature dataset to be projected.
out_coor_system (Coordinate System):
Valid values are a file with a .prj extension (.prj files shipped with ArcGIS
are available at the ArcGIS installation directory in the Coordinate System
folder) or a string representation of a coordinate system. This string
representation can be generated by adding a coordinate system variable to
ModelBuilder, setting the variable's value as desired, then exporting the model
to a Python script. The string can then be copied from the Python script.
transform_method {String}:
This method can be used for converting data between two geographic coordinate
systems or datums. This initially optional parameter may be required if the
input and output coordinate systems have different data.Transformations are bi-
directional. For example, if converting data from WGS
1984 to NAD 1927, you can pick a transformation called NAD_1927_to_WGS_1984_3
and the tool will apply it correctly.
in_coor_system {Coordinate System}:
The coordinate system of the input feature class or dataset.
OUTPUTS:
out_dataset (Geodataset):
The new feature dataset or feature class that has the coordinate system
specified in the output coordinate system parameter.
"""
"""
Demo of Class of python
#!/usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk
class HelloWorld:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_border_width(10)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.button = gtk.Button("Hello World")
self.button.connect("clicked", self.hello)
self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
self.window.add(self.button)
self.window.show_all()
def hello(self, widget):
print 'Hello World'
def delete_event(self, widget, event, data=None):
print "delete event occurred"
return False
def destroy(self, widget, data=None):
print "destroy signal occurred"
gtk.main_quit()
def main(self):
gtk.main()
if __name__ == "__main__":
hello = HelloWorld()
hello.main()
"""
