Map Section — GSTPy documentation

# Map Section

For this example we create a borehole and output it in PNG. We assume that we have a feature class with name “area1” that has some TIN features.

Getting the feature ids

We can get them from a feature class like so.

    feature_classes = ni.list_feature_classes()
    area1_feature_class = next((fc for fc in feature_classes
                                if fc.name == "area1"))
    area1_features = ni.list_features(area1_feature_class)

Or we could get them from a MoMa node like in the following example.

List all child feature ids of a MoMa Node

Setting up the input parameters

    map_rect = GSTPy.Rectangle2d(
        GSTPy.Point2d(5398872, 5667584),
        GSTPy.Point2d(5397630, 5671038),
        width=5000)
    srs = area1_feature_class.srs
    input_params = GSTPy.MapImageParameters(area1_feature_ids, map_rect, srs)

Setting up the output parameters

With a template.

    output_path = r"D:\temp\isec\output"
    template = r"D:\temp\isec\templates\mapSection_template.svg"
    output_params = GSTPy.OutputImageParameters(
        output_path, image_type=GSTPy.ImageType.PNG, template_file_path=template)

With a template and json config.

    import json
    output_path = r"D:\temp\isec\output"
    template = r"D:\temp\isec\templates\mapSection_template.svg"
    json_config = json.dumps({
        "unit": "cm",
        "mapsection-font-size": 0.59,
        "mapsection-font-family": "Sans"
    })
    output_params = GSTPy.OutputImageParameters(
        output_path,
        image_type=GSTPy.ImageType.PNG,
        template_file_path=template,
        json_config=json_config)

Only json config.

Note: intersection and legend image will be separate.

    import json
    json_config = json.dumps({
        "unit": "cm",
        "dpi": 200,
        "mapsection-image-width": 25,
        "mapsection-image-height": 25,
        "legend-image-width": 10,
        "legend-image-height": 20
    })
    output_params = GSTPy.OutputImageParameters(
        output_path, image_type=GSTPy.ImageType.PNG, json_config=json_config)

Performing the intersection

    info = ni.save_map_section_image(input_params, output_params)

Full code sample

    import GSTPy

    # getting the feature ids
    feature_classes = ni.list_feature_classes()
    area1_feature_class = next((fc for fc in feature_classes
                                if fc.name == "area1"))
    area1_features = ni.list_features(area1_feature_class)
    area1_feature_ids = [f.feature_id for f in area1_features]

    # input parameters
    map_rect = GSTPy.Rectangle2d(
        GSTPy.Point2d(5398872, 5667584),
        GSTPy.Point2d(5397630, 5671038),
        width=5000)
    srs = area1_feature_class.srs
    input_params = GSTPy.MapImageParameters(area1_feature_ids, map_rect, srs)

    # output parameters variant 1
    output_path = r"D:\temp\isec\output"
    template = r"D:\temp\isec\templates\mapSection_template.svg"
    output_params = GSTPy.OutputImageParameters(
        output_path, image_type=GSTPy.ImageType.PNG, template_file_path=template)

    # intersection
    info = ni.save_map_section_image(input_params, output_params)