ParcelUtility 1.0.8
dotnet add package ParcelUtility --version 1.0.8
NuGet\Install-Package ParcelUtility -Version 1.0.8
<PackageReference Include="ParcelUtility" Version="1.0.8" />
<PackageVersion Include="ParcelUtility" Version="1.0.8" />
<PackageReference Include="ParcelUtility" />
paket add ParcelUtility --version 1.0.8
#r "nuget: ParcelUtility, 1.0.8"
#:package ParcelUtility@1.0.8
#addin nuget:?package=ParcelUtility&version=1.0.8
#tool nuget:?package=ParcelUtility&version=1.0.8
Parcel Utility
https://www.nuget.org/packages/ParcelUtility/
Parcel Utility is a library for finding ArcGIS parcel boundaries,
downloading snapshots, and importing parcel data. It uses NetTopologySuite for geometry. Set an absolute
HTTP(S) HttpClient.BaseAddress before creating a service.
Find a parcel
using Microsoft.Extensions.Logging.Abstractions;
using ParcelUtility.Boundaries;
using ParcelUtility.Parcels;
var source = new ParcelSource(
"county-a", "County A",
"https://example.com/arcgis/rest/services/parcels/FeatureServer");
using var http = new HttpClient
{
BaseAddress = new Uri(source.ServiceUrl),
Timeout = TimeSpan.FromMinutes(2),
};
http.DefaultRequestHeaders.UserAgent.ParseAdd("my-parcel-client/1.0");
var ct = CancellationToken.None;
var boundaries = ParcelBoundaryServiceFactory.Create(http, NullLoggerFactory.Instance);
var parcel = await boundaries.FindAtAsync(source, latitude: 40.1, longitude: -75.2, ct);
if (parcel is not null)
Console.WriteLine($"{parcel.ParcelId}: {parcel.Geometry.GeometryType}");
The examples below reuse http, source, and ct.
Download a snapshot
using ParcelUtility.Downloads;
var storage = ParcelDownloadStorageFactory.CreateFileSystem("parcel-cache");
var downloader = ArcGisDownloaderFactory.Create(http, storage, NullLoggerFactory.Instance,
additionalRetryPredicate: failure =>
failure.RequestKind == ArcGisRequestKind.ObjectIdPage && failure.ErrorCode == 400);
var manifest = await downloader.Download(
source with { AdditionalFields = ["OWNER_NAME"] },
new DownloadOptions(DownloadBatchSize: 1000, RefreshHours: 168),
ct);
Console.WriteLine($"{manifest.FeatureCount} features: {string.Join(", ", manifest.OutputFields)}");
await using var snapshot = await downloader.OpenSnapshotAsync(source.Id, manifest.SourceVersion, ct)
?? throw new InvalidOperationException("Snapshot is missing.");
Snapshots use gzip-compressed GeoJSON Lines. Interrupted downloads can resume from verified
checkpoints, and transient request failures are retried. Set ForceDownload: true to download
again instead of reusing a valid snapshot, or set MaxFeatures: 100 to limit the download.
Run only one download at a time for a given source and version.
Import typed features
using ParcelUtility.Importing;
var target = new InMemoryImportTarget();
var importer = ParcelSnapshotImporterFactory.Create();
await importer.ImportAsync(snapshot, manifest, target, ct);
foreach (var feature in target.Features)
Console.WriteLine($"{feature.Properties[manifest.ObjectIdField]}: {feature.Geometry?.GeometryType}");
Before committing, the importer checks the snapshot checksum and feature count. To import into a
database, implement IParcelImportTarget and stage writes in its import session until commit.
<details> <summary>Example: an in-memory import target</summary>
using ParcelUtility.Downloads;
using ParcelUtility.Importing;
using ParcelUtility.Parcels;
public sealed class InMemoryImportTarget : IParcelImportTarget
{
public IReadOnlyList<ParcelFeature> Features { get; private set; } = [];
public Task<IParcelImportSession> BeginAsync(SnapshotManifest manifest, CancellationToken ct)
{
ct.ThrowIfCancellationRequested();
return Task.FromResult<IParcelImportSession>(new Session(this));
}
private sealed class Session(InMemoryImportTarget target) : IParcelImportSession
{
private readonly List<ParcelFeature> staged = [];
public Task WriteAsync(ParcelFeature feature, CancellationToken ct)
{
ct.ThrowIfCancellationRequested();
staged.Add(feature);
return Task.CompletedTask;
}
public Task CommitAsync(CancellationToken ct)
{
ct.ThrowIfCancellationRequested();
target.Features = staged.ToArray();
return Task.CompletedTask;
}
public ValueTask DisposeAsync()
{
staged.Clear();
return ValueTask.CompletedTask;
}
}
}
</details>
Query local data first
To check a local database before querying ArcGIS, implement IParcelBoundaryRepository and pass it to the service factory:
IParcelBoundaryRepository repository = yourRepository;
var localFirst = ParcelBoundaryServiceFactory.Create(http, NullLoggerFactory.Instance, repository);
var localParcel = await localFirst.FindAtAsync(source, 40.1, -75.2, ct);
If your store returns bounding-box candidates, implement IParcelBoundaryCandidateSource. The adapter below lets the library check each candidate's exact geometry:
var exactRepository = ParcelBoundaryRepositoryFactory.FromCandidates(yourCandidateSource);
var candidateService = ParcelBoundaryServiceFactory.Create(http, NullLoggerFactory.Instance, exactRepository);
var candidateParcel = await candidateService.FindAtAsync(source, 40.1, -75.2, ct);
Return WGS84 polygons or multipolygons from the repository. When no local parcel matches, the service queries ArcGIS; errors from the local backend are passed through.
Serialize geometry
To preserve elevation coordinates in GeoJSON, create the serializer with dimension 3:
using NetTopologySuite.Geometries;
using NetTopologySuite.IO;
using Newtonsoft.Json;
var serializer = GeoJsonSerializer.Create(new GeometryFactory(new PrecisionModel(), 4326), 3);
using var writer = new JsonTextWriter(Console.Out) { Formatting = Formatting.Indented };
serializer.Serialize(writer, parcel);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Logging.Abstractions (>= 11.0.0)
- NetTopologySuite.IO.GeoJSON (>= 4.0.0)
- Newtonsoft.Json (>= 13.0.4)
- Polly (>= 8.9.1)
- RestEase (>= 1.6.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.