Select to view content in your preferred language

Project shapefile returns blank output

2626
4
01-09-2014 10:00 AM
JasonTaylor
Deactivated User
Pretty simple here, hopefully the solution is obvious to the community.

1. make event layer
2. export event layer to shapefile
3. re-project shapefile

InterpolationCSV = "path-to-csv"
XCoord = "Long"
YCoord = "Lat"
ZValue = "Result"
WorkingDirectory = "path-to-wd"

spRefWGS84 = "path-to-prj"
spRefSPN = "path-to-prj"

arcpy.MakeXYEventLayer_management(InterpolationCSV, XCoord, YCoord, "outXY_Layer", spRefWGS84)
arcpy.FeatureClassToFeatureClass_conversion("outXY_Layer", WorkingDirectory, "processpoints.shp")
arcpy.Project_management(WorkingDirectory + "processpoints.shp", WorkingDirectory + "processpoints2.shp", spRefSPN)


This yields a blank output for processpoints2.shp, no matter where I run it, without error. 

Any suggestions would be appreciated.

Thanks,
Tags (2)
0 Kudos
4 Replies
MattSayler
Frequent Contributor
And the first shapefile turns out ok?
0 Kudos
JasonTaylor
Deactivated User
Yes, the first shapefile works just fine. I'm certain the problem is in the project tool. I'm currently using ogr2ogr as an alternative but it's a messy solution.
0 Kudos
JasonTaylor
Deactivated User
ogr2ogr isn't that bad after all! If anyone else is having difficulty using the project tool in arcpy than I would recommend calling ogr2ogr from subprocess.call(). gdal isn't in my path so I need to call it using the full path to the executable. Here is a post on how to do to the conversion:

http://www.mercatorgeosystems.com/blog-articles/2008/05/30/using-ogr2ogr-to-re-project-a-shape-file/

easy, fast, straightforward and free!
0 Kudos
markdenil
Frequent Contributor
Do you have trailing slashes or back slashes in your WorkingDirectory variable string?
It is surely not really "path-to-wd"...

It is best to avoid them. There are a number of ways to do that.
I usually just explicitly include them inside the string,
even when I am connatenating two or more path strings

for example:
path = r"D:\GIS_Utilities\Tasks\WebProductsImage"   # mxd & gdb path
mxdName = "web_chart_6.mxd"                 # mxd name
theMXD = r"%s\mxd\%s" % (path, mxdName)     # mxd full path
mxd = arcpy.mapping.MapDocument(theMXD)     # mxd object


There are various reasons I do this,
ansd there are more elenet ways to do it.
but the important one here is that there
are no \ or / or \\ at the end of any string.


for a start, try passing explicit path\shapefile strings to the project tool.

Oh, and USE THE CODE FORMATING BUTTON when inserting code in a forum post.
0 Kudos