Giter VIP home page Giter VIP logo

nettopologysuite.io.esri's Introduction

NetTopologySuite.IO.Esri

This library provides forward-only readers and writers for Esri shapefiles.

DBF

Shapefile feature attributes are held in a dBASE format file (.dbf extension). Each attribute record has a one-to-one relationship with the associated shape record. Classes whose name starts with Dbf (eg. DbfReader) provide direct access to dBASE files.

using var dbf = new DbfReader(dbfPath);
foreach (var record in dbf)
{
    foreach (var fieldName in record.GetNames())
    {
        Console.WriteLine($"{fieldName,10} {record[fieldName]}");
    }
    Console.WriteLine();
}

SHP

The main file (.shp extension) is a variable-record-length file in which each record describes a shape with a list of its vertices. Classes whose name starts with Shp (eg. ShpPointReader) provide direct access to main file.

foreach (var geometry in Shapefile.ReadAllGeometries(shpPath))
{
    Console.WriteLine(geometry);
}

SHX

The index file (.shx extension) stores the offset and content length for each record in SHP file. As there is no additional value, this file is ignored during reading shapefiles. Writing SHX data is handled directly by ShpWriter classes.

Shapefile

All three files described above form a shapefile. Unified access to shapefile triplet is provided through classes whose name starts with Shapefile (eg. ShapefilePointReader). Under the hood they are decorators wrapping Dbf and Shp classes.

Reading shapefiles using c# code

foreach (var feature in Shapefile.ReadAllFeatures(shpPath))
{
    foreach (var attrName in feature.Attributes.GetNames())
    {
        Console.WriteLine($"{attrName,10}: {feature.Attributes[attrName]}");
    }
    Console.WriteLine($"     SHAPE: {feature.Geometry}");
    Console.WriteLine();
}

Writing shapefiles using c# code

var features = new List<Feature>();
for (int i = 1; i < 5; i++)
{
    var lineCoords = new List<CoordinateZ>
    {
        new CoordinateZ(i, i + 1, i),
        new CoordinateZ(i, i, i),
        new CoordinateZ(i + 1, i, i)
    };
    var line = new LineString(lineCoords.ToArray());
    var mline = new MultiLineString(new LineString[] { line });

    var attributes = new AttributesTable
    {
        { "date", new DateTime(2000, 1, i + 1) },
        { "float", i * 0.1 },
        { "int", i },
        { "logical", i % 2 == 0 },
        { "text", i.ToString("0.00") }
    };

    var feature = new Feature(mline, attributes);
    features.Add(feature);
}
Shapefile.WriteAllFeatures(features, shpPath);

Encoding

The .NET Framework supports a large number of character encodings and code pages. On the other hand, .NET Core only supports limited list of encodings. To retrieve an encoding that is present in the .NET Framework on the Windows desktop but not in .NET Core, you need to do the following:

  1. Add to your project reference to to the System.Text.Encoding.CodePages.dll.
  2. Put the following line somewhere in your code: Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

Install using NuGet package manager

Stable releases are hosted on the default NuGet feed. You can install them using the following command on the package manager command line

PM> NuGet\Install-Package NetTopologySuite.IO.Esri.Shapefile

nettopologysuite.io.esri's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nettopologysuite.io.esri's Issues

Invalid geometry type provided (Polygon). Expected: Multilinestring

Hello, I have two datasets now: one is LineString data and the other is Polygon data. I added these two datasets to a FeatureCollection and tried to generate a shapefile using Shapefile.WriteAllFeatures. However, I encountered an error message saying "Invalid geometry type provided (Polygon). Expected: Multilinestring." I would like to know if this is because a FeatureCollection cannot contain different types of geometries. How can I solve this problem? Thank you.

code:

    var ntsService = new NtsGeometryServices(new PrecisionModel(), 4326);
    var wktReader = new WKTReader(ntsService);
    var featureCollection = new List<IFeature>();
    foreach (var item in wktArrays)
    {
        var geometry = wktReader.Read(item.Wkt);
        foreach (var name in item.Attributes.GetNames())
        {
            if (item.Attributes.GetType(name) == typeof(object))
            {
                item.Attributes.DeleteAttribute(name);
            }
        }
        var feature = new Feature { Geometry = geometry, Attributes = item.Attributes };
        featureCollection.Add(feature);
    }
    var now = DateTime.Now;
    var folderDate = now.ToString("yyyy") + now.ToString("MM") + now.ToString("dd") + now.ToString("HH")
        + now.ToString("mm") + now.ToString("ss");
    var shapeFilePath = Path.Combine(App.WebHostEnvironment.ContentRootPath, Options.ShapeFilePath, fileName, folderDate);
    if (!Directory.Exists(shapeFilePath))
    {
        Directory.CreateDirectory(shapeFilePath);
    }
    var savePath = Path.Combine(shapeFilePath, fileName);
    Shapefile.WriteAllFeatures(featureCollection, savePath);

Saving geometries with Z=NaN

We're in process of migrating to IO.ESRI from IO.ShapeFile & we have noticed a change in behavior when saving PointZM geometries where Z=NaN

The old version was exporting these NaN values, while the new version converts them to 0.

Checking the code it mentions spec conformance. On the other hand, according to the spec:

Positive infinity, negative infinity, and Not-a-Number (NaN) values are not allowed in shapefiles.

& the library saves X & Y coordinates without any conversion. (Sure, the code mentions "// Avoid performance costs (if you trying to pas NaN as X,Y then you're wrong).")

Unfortunately our software is relying on the behavior of the old version: we need to round-trip coordinates with NaN values.

Before sending a PR I'd be interested in your opinion & if this is something you consider supporting at all.

I was thinking of introducing some kind of "Legacy" or "Loose" behavior switch for exports, similar to the GeometryBuilderMode when importing, but open to other ideas.

Another option would be making the Shapefile static class a bit more extensible & reusable, so I can reproduce the WriteAllFeatures without copying half of the class, by injecting a custom ShapefilePointWriter. This way I could write out-of-spec files without making the library to support out-of-spec files. This would be a bigger refactoring, however. (Esp. that the other writers need to be split, too, e.g. ShpMultiPartBuilder)

Create Shapefile From WKT failed

I want to create a shapefile from wkt, but get this error like this:

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'NetTopologySuite.Geometries.Polygon' to type 'NetTopologySuite.Geo
metries.MultiPolygon'.
   at NetTopologySuite.IO.Esri.Shapefiles.Writers.ShapefileWriter`1.Write(IFeature feature)
   at NetTopologySuite.IO.Esri.Shapefiles.Writers.ShapefileWriter.Write(IEnumerable`1 features)
   at NetTopologySuite.IO.Esri.Shapefile.WriteAllFeatures(IEnumerable`1 features, String shpPath, Encoding encoding, String projection) 

I try to open the debug mode and tracking code, I found that in Shapefile.cs line 185, there are trying to get the parameter's geometry type like this:

var shapeType = features.FindNonEmptyGeometry().GetShapeType();

And in my situation, it always return PolygonZM 😭
I try to search like NetTopologySuite create shp but no answer now. Could anyone give me a point to solve this question? Thanks!!
( I'm not a native English speaker, please bear with me for any grammatical errors, thanks! )

Here is my code:

using System.Text;
using NetTopologySuite.Features;
using NetTopologySuite.IO;
using NetTopologySuite.IO.Esri;

var features = new List<Feature>();
var wktReader = new WKTReader();
var geometry = wktReader.Read($"POLYGON((229884.458362927 2698919.1790506,229878.266318657 2698913.05244554,229872.637726088 2698914.0245398,229870.132848978 2698912.76299454,229868.585854503 2698911.60799823,229862.417875893 2698913.56799102,229859.466886255 2698913.2179918,229854.168905161 2698909.4280045,229832.918531065 2698900.75121021,229826.266555421 2698903.87487001,229815.242942057 2698911.30138916,229814.158096991 2698912.0322406,229802.736136414 2698917.5934203,229787.107090625 2698922.43900198,229770.41744862 2698926.49898628,229758.597689508 2698931.31876844,229754.622568952 2698933.63004125,229756.82934315 2698935.98290305,229758.154520219 2698937.39368305,229761.467578897 2698937.10864875,229772.427440716 2698935.38875568,229785.926793536 2698934.84915899,229801.796838123 2698933.66916467,229811.707603543 2698932.67086896,229818.576179578 2698931.9792722,229834.383317175 2698930.1646309,229840.615502711 2698929.44918301,229859.255237777 2698926.54949485,229875.612191821 2698922.46243583,229879.34506797 2698921.52971422,229884.458362927 2698919.1790506))");
    
var attributes = new AttributesTable
{
    { "Date", new DateTime(2022, 1, 1) },
    { "Content", $"I am No. 1" }
};

var feature = new Feature(geometry, attributes);
features.Add(feature);

Shapefile.WriteAllFeatures(features, @"C:\Users\user\Downloads\test.shp");

Handling of duplicate attribute-names

Hello Esri Team.
First of all thanks for the hard work for the whole NetTopologySuite working with Polygons is so much easier than it should be thanks to your package.

Now to my current issue:

We recently got a bunch of shapefiles with duplicate attribute-names.
I was able to implement my own workaround so i can at least open these files (otherwise NuGet Version 1.0.0 would throw an exception when trying to open it due to trying to Add duplicate Values to a Dictionary)
However now we got shapefiles that actually contain needed Information in some of those dupllicate Attribute-Names.

I absolutely understand that this is not supported because I myself think it's in the exporters responsibility that all attributes have distinct names. However the Shapefiles are sent from government instituts and it's next to impossible to change anything in the near future there no matter how hard we would complain.

I've already pulled the Repository and created my own Version of it which can open shapefiles with duplicate attribute-names. So I'd be willing to implement the change for my version as well, however I'm not that familiar with the repository and if I could get an explanation on what I need to change I could do it myself. (And also pull the code back into the main-repository)

I was thinking of a similar solution to QGIS which imports all duplicate attributes with a trailing "_1" counting upwards for each found duplicate attribute-name.
image

I would appreciate any help. Even if it's just hints about what I have to look out for when implementing this change.

Thanks :)

Antragsschläge 2024 (4).zip
I've also attached a zip-file with this exact issue

Issue in ReadGeometry with a Multipolygon ESRI shapefile

Hi!

first of all, thank you for your library.
I'm inexperienced with ESRI shapefile.
I'm using your library to try to open an ESRI shapefile, modify its attributes and save a new one.
I have found this issue with a MultiPolygon ESRI shapefile and at the moment I'm trying to understand what it is wrong..
I'm calling Shapefile.ReadAllFeatures on the shapefile attached below..
MultiPolygon ReadGeometry(Stream shapeBinary) throws an exception.

If you have any suggestions you are more then welcome.

Thank you,
bye
Francesca
tmpA6A6.zip
Exception

How do I get the Feature Id?

I'm trying to upgrade a project that use to use the older NetTopologySuite.IO.ShapeFile. When I use to export a shape, I would get the esri generated Feature ID as the property "FeatureId". I've tried using GetOptionalId("FID") and GetOptionalId("FeatureID") and neither work.

How to write Shapefile header

I have the NetTopologySuite.IO.Esri.Shapefile.WriteAllFeatures(features, path); working in my code. I have a requirement to set the Shapefile Header with file code, file length, version, shape type, Xmin, Ymin, Xmax, Ymax. Is there documentation on setting the file header with NetTopologySuite.IO.Esri?

Null value

when I want to create a shapefile and insert a null value in it, I get a system object not supported error.
Fine, but the value is an int?

GDBWriter and GDBReader classes removed?

Hello,
I see that this package is the continuation of this package

However I see that at some stage the GDBWriter and GDBReader classes were dropped.

Just wondering if there is a technical reason why they were dropped, and if you would accept PR's to create new versions of these classes?

Add stream support

Add helper methods to open ShapefileReader and ShapefileWriterStream using streams. This will be an alternative to existing methods based on file path:

  • Shapefile.OpenRead(string shpPath, ShapefileReaderOptions options = null)
  • ShapefileShapefileWriter OpenWrite(string shpPath, ShapefileWriterOptions options)

Export shape file with (spatial reference) WKT

Hi.
thank you guys for this library.
I am inexperienced with shape files but I want to export shapefile with it's WKT, when I do export shape file by using the library
with the following code.

       List<Feature> features = new List<Feature>();
       var geoReader = new GeoJsonReader();
       var feature = geoReader.Read<Feature>(jsonData);
       List<Feature> features = new List<Feature>(){feature};
       Shapefile.WriteAllFeatures(features, "C:\\Logs\\test.shp");

it works fine and I got the following files
test.dbf
test.shp
test.shx
test.cpg
but when I try to add these shape file to tool like ArcGIS Pro, I got the following warning
image
What I need to do is to export WKT files with the shapefile.
I except files like test.prj which holds the projects coordinate system
Thanks

DBF * in numeric field

Hi,
I was passed a simple shp file made by QGIS. It errors out on reading in. A quick debug finds a string of * in the numeric ID field. We added the following quick fix:

readval

I wonder if you have a better approach that could be folded in to the repo? File attached.
WallaceMonument.zip

PS is there a nuget for this repo? couldn't locate it on last look.

thanks in advance, and cheers for the work, Matt

nuget out of date

Hi,

Thanks for the great project. The latest fixes to help skip invalid geometry and cope with poor dates are really useful. Can I ask that you publish a fresh nuget so we can refrence it (much nicer than copying your code locally).

Thanks again, Matt

Cannot Write Shapefile with LineStrings using ShapefileWriter

I'm trying to write a shapefile that may contain a mix of LineStrings and MultiLineStrings. I'm getting the writer like so:

var options = new ShapefileWriterOptions(ShapeType.PolyLine, fields)
{
	Projection = GeographicCoordinateSystem.WGS84.WKT
};
using var writer = Shapefile.OpenWrite(shpPath, options);

... code to create DbfFields and set geometry

writer.Write();

When I try to write the file I get a "Cannot cast LineString to MultiLineString" error stemming from the ShapefileWriter class. The override of the Geometry property is trying to cast the Geometry to T.

The Shapefile.OpenWrite() method will return a PolyLineWriter. The PolyLineWriter is a ShapeFileWriter. Hence the error when trying to write a LineString.

If I use Features (as opposed to directly constructing DbfFields) and use writer.Write(Features) it works because Write(Feature) will turn the LineString into a MultiLineString for me in ShpPolyLineWriter.GetShapeGeometry().

But features don't handle null values, due to the issue described in "Null value" (can't determine type). It would be nice if either features handled null values, or writer.Write() could handle LineStrings.

Create Shapefile From WKT failed

Based on @anthea-wu question on Stack overflow:

I want to create a shapefile from wkt by using NetTopologySuite.IO.Esri, but get this error like this:

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'NetTopologySuite.Geometries.Polygon' to type 'NetTopologySuite.Geo
metries.MultiPolygon'.
   at NetTopologySuite.IO.Esri.Shapefiles.Writers.ShapefileWriter`1.Write(IFeature feature)
   at NetTopologySuite.IO.Esri.Shapefiles.Writers.ShapefileWriter.Write(IEnumerable`1 features)
   at NetTopologySuite.IO.Esri.Shapefile.WriteAllFeatures(IEnumerable`1 features, String shpPath, Encoding encoding, String projection) 

Here is my code:

using System.Text;
using NetTopologySuite.Features;
using NetTopologySuite.IO;
using NetTopologySuite.IO.Esri;

var features = new List<Feature>();
var wktReader = new WKTReader();

// I tried wkt with EPSG:4326 and EPSG:3826, but no one work.
var geometry = wktReader.Read($"POLYGON((229884.458362927 2698919.1790506,229878.266318657 2698913.05244554,229872.637726088 2698914.0245398,229870.132848978 2698912.76299454,229868.585854503 2698911.60799823,229862.417875893 2698913.56799102,229859.466886255 2698913.2179918,229854.168905161 2698909.4280045,229832.918531065 2698900.75121021,229826.266555421 2698903.87487001,229815.242942057 2698911.30138916,229814.158096991 2698912.0322406,229802.736136414 2698917.5934203,229787.107090625 2698922.43900198,229770.41744862 2698926.49898628,229758.597689508 2698931.31876844,229754.622568952 2698933.63004125,229756.82934315 2698935.98290305,229758.154520219 2698937.39368305,229761.467578897 2698937.10864875,229772.427440716 2698935.38875568,229785.926793536 2698934.84915899,229801.796838123 2698933.66916467,229811.707603543 2698932.67086896,229818.576179578 2698931.9792722,229834.383317175 2698930.1646309,229840.615502711 2698929.44918301,229859.255237777 2698926.54949485,229875.612191821 2698922.46243583,229879.34506797 2698921.52971422,229884.458362927 2698919.1790506))");

// Also tried this but not work too.
// var geometry = wktReader.Read(wkt) as Polygon;
    
var attributes = new AttributesTable
{
    { "Date", new DateTime(2022, 1, 1) },
    { "Content", $"I am No. 1" }
};

var feature = new Feature(geometry, attributes);
features.Add(feature);

Shapefile.WriteAllFeatures(features, @"C:\Users\user\Downloads\test.shp");

Do not write SHP files that are over 2gb

The ShapeWriter can produce shp files that are over 2gb (int.MaxValue bytes). Unfortunately, ArcGis Pro (and possibly other tools), cannot actually correctly read such large files.

I had some shapefiles that I created that had produced slightly more than 2gb of shape data, and I originally thought it was some sort of arcgis bug that my 300,000 row shapefile was stopping at 269,861 rows. Apparently that was the cut off point where my file was over the 2gb limit. While my dbf was small enough to show the rows, the remaining feature polygons could not be read.

If the SHP length field exceeds int.MaxValue an invalid operation exception should be thrown as the file is likely unusable.

Allow DbfCharacterField support 255 length.

Hi!

Sometimes, character fields in dbf file (inside ShapeFile) has 255 chars length. This one generates error during reading.

a posible solution:

--- a/src/NetTopologySuite.IO.Esri.Shapefile/Dbf/Fields/DbfCharacterField.cs
+++ b/src/NetTopologySuite.IO.Esri.Shapefile/Dbf/Fields/DbfCharacterField.cs
@@ -22,7 +22,7 @@ public DbfCharacterField(string name, int length = MaxFieldLength) : this(name,
}

     internal DbfCharacterField(string name, int length, Encoding encoding)
  •        : base(name, DbfType.Character, Math.Min(length, MaxFieldLength), 0)
    
  •        : base(name, DbfType.Character, Math.Min(length, MaxFieldLength+1), 0)
       {
           _encoding = encoding;
       }
    

TIA,
regards

Problem with saving attributes readed from existing file

I'm trying to save shape file after reading it, but I receive exception

System.NotSupportedException: Unsupported dBASE field type: RuntimeType (System.Object)

From my investigation it looks like that problem is when field has null value

Sample code and shp file used to generate error attached
sample.zip

Project status

Is there any status or ETA on this project first release?

Reprojection

Is there any way to reproject the geometries to a new coordinate system once they've been read in from the shape file? This reader doesn't seem to take into account the .prj file. Do I need to use an additional nuget package?

Invalid Polygon Issue

Hi all,

I've been using your library recently, it's really nice and easy to use!

I have noticed however, that there are a few shapefiles that are unable to be read in, and thought best to raise this as a potential issue.

An exception is thrown when this line is executed in my project:
foreach (var feature in Shapefile.ReadAllFeatures(filePath)) { ... }

The exception thrown:
NetTopologySuite.IO.Esri.ShapefileException : {"Invalid polygon geometry.":null}

StackTrace: at NetTopologySuite.IO.Esri.Shp.Readers.ShpPolygonReader.BuildMultiPolygon(ShpMultiPartBuilder parts)
at NetTopologySuite.IO.Esri.Shp.Readers.ShpPolygonReader.ReadGeometry(Stream stream, MultiPolygon& geometry)
at NetTopologySuite.IO.Esri.Shp.Readers.ShpReader1.ReadCore(Int32& skippedCount) at NetTopologySuite.IO.Esri.Shapefiles.Readers.ShapefileReader1.Read(Boolean& deleted)
at NetTopologySuite.IO.Esri.Shapefiles.Readers.ShapefileReader1.Read(Boolean& deleted, Feature& feature) at NetTopologySuite.IO.Esri.Shapefiles.Readers.ShapefileReader.FeatureEnumerator.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at NetTopologySuite.IO.Esri.Shapefile.ReadAllFeatures(String shpPath, ShapefileReaderOptions options)

I've attached a couple of the shapefile examples, that cause the same exception to be thrown just below,
Example Shapefiles.zip
FYI: Shapefiles are from here: https://hub.arcgis.com/documents/NSTAUTHORITY::-nsta-offshore-zipped-shapefiles-wgs84/about

Thanks in advance for your help,
Emma

Editing attribute data of an existing shapefile, using VB.NET

Hi all,

I am applying your library in order to adjust attribute values in an existing polygon shapefile.
What is the best way to approach this? Here is my code so far. However it does not work and returns an error saying the file is already in use by another process. Also if I change the results filename I get an error: "value cannot be null, parameter name: Geometry"

        Dim ShapeReader As New NetTopologySuite.IO.Esri.Shapefiles.Readers.ShapefilePolygonReader("full.shp")
        Dim myFeature As NetTopologySuite.Features.Feature
        Dim Deleted As Boolean
        While ShapeReader.Read(Deleted, myFeature)
            myFeature.Attributes.Item("GFEIDENT") = "new value"
        End While

        Dim options As New ShapefileWriterOptions(ShapeReader)

        Using myWriter As New NetTopologySuite.IO.Esri.Shapefiles.Writers.ShapefilePolygonWriter("full.shp", options)
            myWriter.Write()
        End Using

Thanks in advance for your help!
Siebe Bosch

Multi-polygon bringing in extra/redundant polygons?

Hi all,

I've been testing out reading in shapefiles with your library, to look at replacing another library that we currently use that doesn't handle text encoding very well (https://github.com/abfo/shapefile).

However, I've noticed that reading in multi-polygon shapefiles with your library, in a few examples, seems(?) to read in unexpected polygons.

I don't think I've described the issue very well, but below I've got 2 screen shots, rendering the shapefile in question, using the Microsoft Bing Map control, which hopefully showcases what I'm describing.

The first image is from the other shapefile library
OGA_Geological_Sub_WGS84_expected

The 2nd image is from your library, which has some additional polygons being read in and rendered.
OGA_Geological_Sub_WGS84_Esri_lib

I'm not overly familiar with shapefiles, so this may not be an issue with your library, but maybe with the shapefile itself(?), or it could be something that we need to handle ourselves, after we've read in the shapefiles?
I thought I would raise this, in case anyone had some ideas as to what would cause this, and whether it's something that could be fixed up somehow.

The Geometries are read in using: foreach (var feature in Shapefile.ReadAllFeatures(filePath)){ ... }

The Shapefile I used for this example:
Example Shape file.zip

Apologies if this isn't an issue,
Thanks in advance,

Emma

Repository structure

Before I get started I would like clarify proposed repository structure.

  1. My NetTopologySuite/NetTopologySuite.IO.ShapeFile#69 pull request introduced two new VS projects: NetTopologySuite.IO.Esri.Core and NetTopologySuite.IO.Esri. The former provides shapefile readers and writers as vanilla .NET Standard 2.0 library without any dependencies. The latter is a wrapper around Core project which gives NTS geometries instead of bunch of collections of coordinates. This separation causes some issues. For example coordinates are first loaded into plain Array and then copied to NTS' CoordinateSequence. It would be more efficient to load them directly from binary into CoordinateSequence. Furthermore the Core project doesn't contain any geometry logic (line length, polygon area, ...). Because of that some issues will be very hard to fix directly in Core project. For example fixing NetTopologySuite/NetTopologySuite.IO.ShapeFile#70 will be much easier having NTS' LinearRing.IsCCW property. For that reasons I would like to combine those two projects into one project which is tightly integrated with NTS library.
  2. We can consider moving dBASE part into separate project without NTS dependencies. After doing so one would be able to read/write dBASE tables without referencing NTS dependencies. As my implementation uses "Esri flavored" dBASE format it fits to this repository very well.
  3. I'm not a fan of maintaining NetTopologySuite.IO.GDB anymore
  4. Project naming convention - shouldn't the project names correspond strictly to NetTopologySuite.IO.Esri?
    • NetTopologySuite.IO.Esri.Shapefile
    • NetTopologySuite.IO.Esri.GDB
    • [NetTopologySuite.IO.Esri.Dbase]
    • [NetTopologySuite.IO.Esri.EnterpriseGeodatabase]

What do you think, @FObermaier?

Is there a way to get shapefile field aliases?

Dbf has a limit of 10 characters in fieldnames, but when I view some shapefiles in arcgis pro, I can see the real field name like RECORDED_1 and then an Alias for the field like Recorded department

I would like to be able to view the aliases.

Read a prj

How do I read a prj and us it with the shape file(s)?

Reading in invalid dates

Hi all,

I think this may be a non-issue, but I am getting an exception when trying to read in this shapefile,

The shapefile:
Example Shapefile.zip

The exception:
{"The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar."}

at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style)
\r\n at NetTopologySuite.IO.Esri.Dbf.Fields.DbfDateField.ReadValue(Stream stream)
\r\n at NetTopologySuite.IO.Esri.Dbf.DbfReader.Read(Boolean& deleted)
\r\n at NetTopologySuite.IO.Esri.Shapefiles.Readers.ShapefileReader1.Read(Boolean& deleted) \r\n at NetTopologySuite.IO.Esri.Shapefiles.Readers.ShapefileReader1.Read(Boolean& deleted, Feature& feature)
\r\n at NetTopologySuite.IO.Esri.Shapefiles.Readers.ShapefileReader.FeatureEnumerator.MoveNext()
\r\n at System.Linq.Buffer1..ctor(IEnumerable1 source)
\r\n at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
\r\n at NetTopologySuite.IO.Esri.Shapefile.ReadAllFeatures(String shpPath, ShapefileReaderOptions options)

I think this may be an issue with the shapefile itself, as the field MAPDATE has dates stored as 00000000 in the attached .dbf file, (which could be causing this issue perhaps?).

But I wanted to confirm whether this is an error case that your library should be handling, or whether it's an issue with the shapefile, that should be fixed up, before reading in.

The shapefile is read in by: foreach (var feature in Shapefile.ReadAllFeatures(filePath))

Thanks in advance,

Emma

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.