0

enter image description hereI have a large txt file with x,y,z format. The file size is almost 8 GB. So I don’t want to process in ArcMAP. What I wanted to do is, I have a end coordinates for polygon shapefile and i have converted that nodes into x min, ymin, x max, y max and I wanted to Clip all the points within that polygon and save a clipped version into a txt file. My point is how I am going to clip a txt file with a bounding polygon?

Can you provide any Python, R and GDAl/ogr2ogr code?

  • What is the Z value of your points? – camdenl Oct 22 '14 at 21:10
  • The shape of the polygon is "square". Can i clip a xyz text file with a square polygon without creating a feature class. I just wanted to get the text file having set of points with that square polygon. My XY points are scattered and Z is the Elevation over the point. – user37082 Oct 22 '14 at 22:50
0

With the updated question, the working directory has the name "LAS", which tells me this is LiDAR data. If you have LAS files, use these. Otherwise, convert your files to this much more efficient format using LAStools or libLAS (via OSGeo4W on Windows). First use txt2las on a headerless ASCII file, parsing X, Y, and Z fields:

txt2las --verbose -parse xyz input.xyz output.las

Then clip it to another LAS file using las2las, or to a text file with las2txt. There are many more utilities, including a LAS viewing program for Windows with LAStools.

  • I have tried the way u have mentioned but when i have again converted that output.las file into txt, then it says "Can't open file LAS", "Can't open lasreadertxt with file name LAS". Is there any way we can do it in GDAL/ogr2ogr straight away. – user37082 Oct 30 '14 at 16:56
3

This is straightforward with ogr2ogr. You may need some tricks to get OGR to understand the structure of your file, see the CSV driver if you have difficulties.

ogr2ogr -spat xmin ymin xmax ymax -f CSV clipped.csv input.csv

You can also use a shapefile dataset to clip using -clipsrc in combination with -clipsrcsql, -clipsrclayer, and/or -clipsrcwhere options.

  • How to Install ogr2ogr at my workstation. Is there any R or Python code available for the same task? – user37082 Oct 24 '14 at 17:57
  • It is installed with GDAL, often packaged as gdal-bin. For Windows, install with OSGeo4W. – Mike T Oct 24 '14 at 23:59
  • I have installed GDAL/ogr2ogr. I have placed same code as above but it gives me usage and advanced options details. Can you please help me out over here...Thx Mike!! – user37082 Oct 29 '14 at 20:33
  • update your question to show the command you tried and errors (except for the usage info) – Mike T Oct 29 '14 at 20:40
  • Updated my question!! Please take a look at it now – user37082 Oct 29 '14 at 21:05
1

What shape is your polygon shapefile? Ie. is it a rectangle or is it convoluted. If it is the former, you just have to determine whether the XYZ values of your points is within the boundary defined by a rectangle (there will be max and min Easting and Northing values), but if it is the latter, I suspect that you can't do what you are asking without first making the point file spatial (adding it to Arc or other GIS package and creating a feature class). Even at 8GB in size if you are just clipping it with one polygon it won't take long. The whole process (creating a feature class, and clipping it) should only take a few minutes.

  • The shape of the polygon is "square". Can i clip a xyz text file with a square polygon without creating a feature class. I just wanted to get the text file having set of points with that square polygon. My XY points are scattered and Z is the Elevation over the point. – user37082 Oct 22 '14 at 22:24
0

No, You can't clip it unless you make the XYZ text file spatial. It is the nature of clipping. You could write a query that determines the Extent of the square and then exclude any points that have values outside it, but that is more work than just clipping.

What GIS software package have you got?

  • Txt file and Shapefile are spatial. I am using ArcGIS but I would like to do this task in R or python – user37082 Oct 24 '14 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy